home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue41 / Clinic / CPanelU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-11-22  |  1.3 KB  |  64 lines

  1. unit CPanelU;
  2.  
  3. interface
  4.  
  5. uses
  6.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ListBox1: TListBox;
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure ListBoxDblClick(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.DFM}
  26.  
  27. uses
  28.   ShellAPI;
  29.  
  30. procedure TForm1.FormCreate(Sender: TObject);
  31. {$ifdef Windows}
  32. const
  33.   MAX_PATH = 255;
  34. {$endif}
  35. var
  36.   SysDirC: array[0..MAX_PATH] of Char;
  37.   SysDir: String;
  38.   SearchRec: TSearchRec;
  39. begin
  40.   GetSystemDirectory(SysDirC, SizeOf(SysDirC));
  41.   SysDir := StrPas(SysDirC);
  42.   if FindFirst(SysDir + '\*.cpl', faAnyFile, SearchRec) = 0 then
  43.     try
  44.       repeat
  45.         ListBox1.Items.Add(UpperCase(SearchRec.Name));
  46.       until FindNext(SearchRec) <> 0;
  47.     finally
  48.       FindClose(SearchRec);
  49.     end;
  50. end;
  51.  
  52. procedure TForm1.ListBoxDblClick(Sender: TObject);
  53. var
  54.   Param: String;
  55.   ParamC: array[0..255] of Char;
  56. begin
  57.   Param := 'shell32.dll,Control_RunDLL ' + ListBox1.Items[ListBox1.ItemIndex];
  58.   Caption := Param;
  59.   StrPCopy(ParamC, Param);
  60.   ShellExecute(Handle, nil, 'RunDll32.exe', ParamC, nil, sw_ShowNormal)
  61. end;
  62.  
  63. end.
  64.